package com.jht.bletool2java.activity.splash;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager;
import android.widget.Toast;

import com.jht.bletool2java.R;
import com.jht.bletool2java.activity.BaseActivity;
import com.jht.bletool2java.activity.homepage.HomeActivity;
import com.jht.bletool2java.util.ActivityUtil;


public class SplashActivity extends BaseActivity implements ISplash.UI {
    private static final String TAG = "SplashActivity";


    private ISplash.Presenter splashPresenter;

    @SuppressWarnings("all")
    private Runnable startHomeActivity = new Runnable() {
        @Override
        public void run() {
            ActivityUtil.startHomeActivity(SplashActivity.this);
        }
    };


    @Override
    public int getLayoutID() {
        return R.layout.activity_splash_lib;
    }

    @Override
    public void initViewAndPresenter() {
        splashPresenter = new SplashPresenter(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //onCreate方法之后，至此所有ui初始化逻辑，都应该完成，借下来调用业务逻辑
        splashPresenter.startSplash();
    }

    @Override
    public void showVersionUpdateInformation() {
        //展示新版本信息
        Toast.makeText(this,"展示新版本信息",Toast.LENGTH_LONG).show();
    }

    @Override
    public void startHomeActivity() {
        Intent intent = new Intent(this, HomeActivity.class);
        startActivity(intent);
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(DEBUG){
            Log.d(TAG, "onDestroy: ");
        }
    }

    protected void setStatus() {
        if(DEBUG){
            Log.d(TAG, "setStatus: ");
        }
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

}